home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Games Collection 1
/
software vault.zip
/
software vault
/
CDR10
/
YICN23.ZIP
/
DOC
/
PLATFORM.DOC
< prev
next >
Wrap
Text File
|
1993-03-06
|
5KB
|
162 lines
Platform games like Jill of the Jungle and the Commander Keen series have
been very successful. However, they all follow some similar patterns which
can be put together in a library. The platform game routines here should
ease development of such a game considerably.
#ifndef PLATFORM_H
#define PLATFORM_H
#include "factor.h"
#define FLOORHEIGHT 40
#define FLOOR 0x01 //floor bit.
class platformBeast : public factor
{
public:
int xMomentum, yMomentum, gravity, moveIncrement, jumpIncrement;
int hitPoints, alignment, damage;
platformBeast() {xMomentum = alignment = damage = yMomentum = hitPoints= moveIncrement = jumpIncrement = 0;
gravity = 2;};
virtual void advance(void);
void die(void);
enum command {goLeft, goRight, jump};
int targetTerrain() {return mymap->mapData[(mapX*mymap->squareWidth + squareX + xMomentum) / (mymap->squareWidth)]
[(mapY*mymap->squareWidth + squareY + yMomentum) / (mymap->squareWidth)].myTerrainType;};
void go(command myCommand);
};
class player;
class missile : public platformBeast
{
public:
int range;
int missileNumber;
int damage;
player * owningPlayer;
missile(void) {gravity = 0; range = missileNumber = damage = 0; owningPlayer = NULL;}
virtual void advance(void);
};
class player : public platformBeast
{
public:
missile * myMissiles[5];
int numMissiles; //number of missiles he can fire
int missileType;
player(void) : platformBeast() {myMissiles[0] = myMissiles[1] = myMissiles[2] = myMissiles[3]=
myMissiles[4] = NULL;};
void fireMissile(void);
virtual missile * missileGenerator(int missileType) {return NULL;};
int hitWithMissile(platformBeast * target);
};
class crawler : public platformBeast
{
public:
virtual void advance(void);
};
#endif
#ifndef PLATFORM_H
#define PLATFORM_H
#include "factor.h"
#define FLOORHEIGHT 40
#define FLOOR 0x01 //floor bit.
class platformBeast : public factor
This is the generic object in the platform game, be it monster, player, or
whatever.
{
public:
int xMomentum, yMomentum, gravity, moveIncrement, jumpIncrement;
These contain the current situation of the platformBeast. Different beasts
can have different gravities (even reverse gravities). MoveIncrement and
jumpIncrement affect the speed of the character's movement.
int hitPoints, alignment, damage;
Hit points have to do with life. Alignment is used if you want platform
beasts that will help the player. Damage is how much damage a creature causes
if it hits one of a different alignment.
platformBeast() {xMomentum = alignment = damage = yMomentum = hitPoints= moveIncrement = jumpIncrement = 0;
gravity = 2;};
Constructor.
virtual void advance(void);
Advances the beast.
void die(void);
Kills the beast.
enum command {goLeft, goRight, jump};
Commands you can give to a beast.
int targetTerrain() {return mymap->mapData[(mapX*mymap->squareWidth + squareX + xMomentum) / (mymap->squareWidth)]
[(mapY*mymap->squareWidth + squareY + yMomentum) / (mymap->squareWidth)].myTerrainType;};
Returns the type of terrain the beast is about to enter. Handy for checking
if critters are about to fall off a ledge.
void go(command myCommand);
Gives a command to a platformBeast.
};
class player;
class missile : public platformBeast
{
public:
int range;
How many frames the missile will be active.
int missileNumber;
# of the missile in the player's inventory.
int damage;
Damage caused by the missile.
player * owningPlayer;
Who owns the missile?
missile(void) {gravity = 0; range = missileNumber = damage = 0; owningPlayer = NULL;}
virtual void advance(void);
Constructor and advancer.
};
class player : public platformBeast
{
public:
missile * myMissiles[5];
Array of missiles.
int numMissiles; //number of missiles he can fire
int missileType; //type of missile
player(void) : platformBeast() {myMissiles[0] = myMissiles[1] = myMissiles[2] = myMissiles[3]=
myMissiles[4] = NULL;};
Constructor.
void fireMissile(void);
Hurm.
virtual missile * missileGenerator(int missileType) {return NULL;};
Produces a missile of the appropriate type.
int hitWithMissile(platformBeast * target);
Did any missiles hit the beast?
};
class crawler : public platformBeast
Crawls back and forth on a ledge until it reaches the edge. Not much to it.
{
public:
virtual void advance(void);
};
#endif